//
//  shadowView.m
//  BKLoading
//
//  Created by TOPTEAM on 2016/11/23.
//  Copyright © 2016年 TOPTEAM. All rights reserved.
//

#import "shadowView.h"

@implementation shadowView

-(id)initShadow{
    self = [super init];
    self.backgroundColor=[UIColor clearColor];
    return self;
}

- (void)drawRect:(CGRect)rect {
    
    
    // 传的是不是正方形，因此就可以绘制出椭圆圆了
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:self.bounds];
    
    // 设置填充颜色
    [self.Color set];
    [path fill];
    
    // 设置画笔颜色
    UIColor *strokeColor = [UIColor clearColor];
    [strokeColor set];
    
    // 根据我们设置的各个点连线
    //    [path stroke];
    
    //新建图层——绘制上述路径
    CAShapeLayer *layer = [[CAShapeLayer alloc] init];
    layer.fillColor =self.Color.CGColor;
    layer.strokeColor = strokeColor.CGColor;
    layer.lineWidth = path.lineWidth;
    layer.path = path.CGPath;
    
    
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:NSStringFromSelector(@selector(strokeEnd))];
    animation.fromValue = @0;
    animation.toValue   = @1;
    animation.duration  = 2;
    //和上对应
    [layer addAnimation:animation forKey:NSStringFromSelector(@selector(strokeEnd))];
    [self.layer addSublayer:layer];
    
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end















































